// -*- coding: utf-8 -*- 
/**
 * Project: AlgorithmsLearn
 * Creator: yanking
 * Create time: 2022-02-27 10:29
 * IDE: IntelliJ IDEA
 * Introduction:
 */
package com.LeetCodeT.Greedy;

public class MaxArea {
    // 求水池的最大面积
    // 1 朴素方法，一次遍历
    public int maxArea(int[] height) {
        int len = height.length;
        int max = 0;
        for (int i = 0; i < len; i++) {
            for (int j = i + 1; j < len; j++) {
                int l = j - i;
                int h = Math.min(height[i], height[j]);
                max = Math.max(max, h * l); // 更新面积数据
            }
        }
        return max;
    }
}
